<template>
	<view class="content">
		<view class="title">
			<view class="header">
				<view class="img">
					<image style="width: 180upx;height: 180upx;" :src="imageUrl"></image>
				</view>
				<view class="text">
					<text>{{name}}</text>
					<view style="display: flex;justify-content: space-between;margin-top: 60upx;">
						<text>￥{{price}}</text>
						<text>x{{nums}}</text>
					</view>
				</view>
			</view>
			<view style="margin-top: 20upx;">
				<text style="font-size: 30upx; padding-left: 20upx;">产品描述</text>
				<textarea v-model="content" style="border: 2upx solid #888888;width: 94%;margin: 0 20upx 0 20upx;height: 200upx;"
				 placeholder="请对我们的产品进行描述"></textarea>
			</view>
			<button type="primary" style="background: #D7000F;margin: 20upx;" @click="goodsComment()">提交</button>
		</view>
	</view>
</template>
<script>
	import {
		get,
		post,
		showToast
	} from '../../js/common';
	export default {
		data() {
			return {
				id:'',
				userId: '',
				nums: '',
				price: '',
				name: '',
				imageUrl: '',
				orderItemId: '',
				content: ''
			}
		},
		onLoad(option) {
			this.id = option.id
			this.nums = option.nums
			this.price = option.price
			this.name = option.name
			this.imageUrl = option.imageUrl
		},
		methods: {
			goodsComment() {
				try {
					this.userId = uni.getStorageSync('userId')
					const params = {
						userId: this.userId,
						orderItemId: this.id,
						content: this.content
					}
					post('mobileapi/comment/goodsComment', params).then(res => {
						if(res.code == 0){
							uni.showToast({
								title:'评价成功',
								icon:'none'
							})
							uni.navigateBack(-1)
						}
						else{
							uni.showToast({
								title:'评价失败',
								icon:'none'
							})
							return
						}
					})
				} catch (e) {}
			}
		}
	}
</script>
<style>
	.title {
		width: 100%;
		height: 500upx;
		background: #ffffff;
	}

	.header {
		border-bottom: 2upx solid #E6E6E6;
		display: flex;
		margin: 20upx 20upx 0 20upx;
		padding-top: 10upx;
		height: 200upx;
	}

	.img {
		width: 180upx;
		height: 180upx;
	}

	.text {
		margin: 20upx 0 0 10upx;
		font-size: 26upx;
		color: #666666;
	}
</style>
